<template>
  <div class="container">
    <el-dialog
      title="修改学科"
      :visible="isShow"
      width="30%"
      center
      @close="btnCancle"
    >
      <el-form label-width="80px" v-model="fromVla">
        <el-form-item label="学科名称">
          <el-select placeholder="请选择活动区域" v-model="fromVla.subjectID">
            <el-option
              v-for="(item, index) in list"
              :key="index"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="目录名称">
          <el-input
            placeholder="请输入学科名称"
            v-model="fromVla.directoryName"
          />
        </el-form-item>
      </el-form>
      <span slot="footer">
        <el-button @click="btnCancle">取 消</el-button>
        <el-button type="primary" @click="btnOk">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { simple, add } from '../../api/hmmm/directorys'

export default {
  props: {
    isShow: {
      type: Boolean,
      required: true
    }
  },
  data() {
    return {
      fromVla: {
        subjectID: null,
        directoryName: ''
      },
      list: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    async getList() {
      const { data } = await simple()
      this.list = data
      console.log(this.list)
    },
    async btnOk() {
      await add(this.fromVla)
      this.$message.success('添加成功')
      this.$emit('list')
      this.$emit('update:isShow', false)
    },
    btnCancle() {
      this.fromVla = {
        subjectID: null,
        directoryName: ''
      }
      this.$emit('update:isShow', false)
    }
  }
}
</script>

<style scoped lang="less"></style>
